package javaweek4;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

class PersonOverride{
	private String name;
	private boolean gender;
	private int age;
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public boolean isGender() {
		return gender;
	}
	public void setGender(boolean gender) {
		this.gender = gender;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
	public PersonOverride(String name, int age, boolean gender) {
		this.name = name;
		this.gender = gender;
		this.age = age;
	}
	public PersonOverride() {
		this( "default" , 1 , true);
	}
	@Override
	public String toString() {
		return name + "-" +  age + "-" + gender ;
	}
	/**
	 * 
	 */
	public boolean equals(PersonOverride obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		PersonOverride other = (PersonOverride) obj;
		if (age != other.age)
			return false;
		if (gender != other.gender)
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}	
}

public class Extends {

	private static int flag;

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int n1=sc.nextInt();
		int n2=sc.nextInt();
		int count=0;
		PersonOverride[] person1=new PersonOverride[n1];
		PersonOverride[] person2=new PersonOverride[n2];
		for (int i = 0; i < n1; i++) {
			person1[i]=new PersonOverride();
		}
		for (int i = 0; i < n2; i++) {
			PersonOverride other = new PersonOverride(sc.next(),sc.nextInt(),sc.nextBoolean());
			if( i == 0 ){
				person2[i] = other;
				continue;
			}
			for (int j = 0; j < i; j++) {
				if(person2[j] != null)
				if(other.equals(person2[j])) flag = 1;
			}
			if (flag == 0){
				person2[i] = other;
			}
			flag = 0;
		}
		for (int j1 = 0; j1 < person1.length; j1++) {
			System.out.println(person1[j1]);
		}
		for (int j2 = 0; j2 < person2.length; j2++) {
			if(person2[j2] != null){
			System.out.println(person2[j2]);
			count++;
			}
		}
		System.out.println(count);
		System.out.println(Arrays.toString(PersonOverride.class.getConstructors()));
		sc.close();
	}

}
